<?php
if(!isset($AppUI->id) || $AppUI->id <=0 || ($AppUI->id > 0 && $AppUI->type < ROLE_LEADER)) {
	redirect(HOST_BACKEND);
}
$this->load->model('admin_model', 'admin');	
$this->load->model('section_model', 'section');	
$this->load->model('permission_model', 'permission');	
$intAdminId = $this->input->get('adminid', 0);
$intRoomId  = $AppUI->type < ROLE_ADMINISTRATOR ? $AppUI->roomid : -1;
$adminList  = $this->admin->getEmployee($AppUI->type, $intRoomId);
$adminInfo  = null;
$arrAPerm   = null;
if($intAdminId > 0) {
    $adminInfo      = $this->admin->get($intAdminId);
    $sectionList    = $this->section->getSection();
    if(isset($sectionList)) {
        foreach($sectionList as $row) {
    		$row['perm'] = $this->permission->getPermission($intAdminId, $row['sectionid']);
    		$arrAPerm[]	 = $row;
    	}
    }
}
$this->smarty->assign('arrRoom', $arrRoom);
$this->smarty->assign('arrAPerm', $arrAPerm);
$this->smarty->assign('admins', $adminList);
$this->smarty->assign('info', $adminInfo);
$this->smarty->display('permission/index.tpl');
